package org.service.impl;

import java.util.List;


import org.bean.O2ranksongs;
import org.dao.HotSongsDao;
import org.service.HotSongsService;
import org.util.PageBean;

public class HotSongsServiceImpl implements HotSongsService {
		
	private HotSongsDao HotSongsDao;
	private O2ranksongs	O2ranksongs;
	
	
	@SuppressWarnings("unchecked")
	public PageBean queryForPageHotSongs(int pageSize, int page) {
		final String hql;
		
		hql = "from O2ranksongs s  order by s.hot desc ";
		
		int allRow = HotSongsDao.getAllRowCount(hql);
		int totalPage = PageBean.countTotalPage(pageSize, allRow);
		final int offset = PageBean.countOffset(pageSize, page);
		final int length = pageSize;
		final int currentPage = PageBean.countCurrentPage(page);
		
		List<O2ranksongs> list = HotSongsDao.queryForPageHotSongs(hql, offset, length);
		
		PageBean pageBean = new PageBean();
		pageBean.setPageSize(pageSize);
		pageBean.setCurrentPage(currentPage);
		pageBean.setAllRow(allRow);
		pageBean.setTotalPage(totalPage);
		pageBean.setList(list);
		pageBean.init();
		
		return pageBean;
	}

	@Override
	public O2ranksongs SelectMusicByid(int mid) {
		
		return this.HotSongsDao.SelectMusicByid(mid);
	}
	
	
	public HotSongsDao getHotSongsDao() {
		return HotSongsDao;
	}


	public void setHotSongsDao(HotSongsDao hotSongsDao) {
		HotSongsDao = hotSongsDao;
	}


	public O2ranksongs getO2ranksongs() {
		return O2ranksongs;
	}


	public void setO2ranksongs(O2ranksongs o2ranksongs) {
		O2ranksongs = o2ranksongs;
	}



	
	
	

}
